//
//  MJDIYAutoFooter.m
//  MJRefreshExample
//
//  Created by MJ Lee on 15/6/13.
//  Copyright © 2015年 小码哥. All rights reserved.
//

#import "XHHomePageFooter.h"
#import "GKLoadingView.h"
@interface XHHomePageFooter()
@property (weak, nonatomic) UILabel *label;
@property (weak, nonatomic) GKLoadingView *loadingView;
@end

@implementation XHHomePageFooter
#pragma mark - 重写方法
#pragma mark 在这里做一些初始化配置（比如添加子控件）
- (void)prepare
{
    [super prepare];
    
    // 设置控件的高度
    self.mj_h = 40.0f;
    
    // 添加label
    UILabel *label = [[UILabel alloc] init];
    label.textColor = C153;
    label.font = [UIFont boldSystemFontOfSize:14];
    label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:label];
    self.label = label;
    
    [self setupLodingView];

        
}

- (void)setupLodingView{
    GKLoadingView *loadingView = [GKLoadingView loadingViewWithFrame:CGRectMake(16,20, 20, 20) style:GKLoadingStyleIndeterminateMask];
    loadingView.radius = 10;
    loadingView.lineWidth = 1;
    [self addSubview:loadingView];
    self.loadingView = loadingView;
    
    [self.loadingView startLoading];
}

#pragma mark 在这里设置子控件的位置和尺寸
- (void)placeSubviews
{
    [super placeSubviews];
    
    CGSize size = [RPAppManager getTextSizeWithText:@"搜索中..." font:[UIFont boldSystemFontOfSize:14] maxSize:CGSizeMake(kScreenW - 64, MAXFLOAT)];
    
    self.label.size = size;
    self.label.cl_centerY = self.loadingView.cl_centerY;
    self.label.cl_x = 64;

}

#pragma mark 监听scrollView的contentOffset改变
- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change
{
    [super scrollViewContentOffsetDidChange:change];
    
}

#pragma mark 监听scrollView的contentSize改变
- (void)scrollViewContentSizeDidChange:(NSDictionary *)change
{
    [super scrollViewContentSizeDidChange:change];
    
}

#pragma mark 监听scrollView的拖拽状态改变
- (void)scrollViewPanStateDidChange:(NSDictionary *)change
{
    [super scrollViewPanStateDidChange:change];
    
}

#pragma mark 监听控件的刷新状态
- (void)setState:(MJRefreshState)state
{
    MJRefreshCheckState;
    switch (state) {
        case MJRefreshStateIdle:
            self.label.text = @"搜索中...";
            break;
        case MJRefreshStateRefreshing:
            self.label.text = @"搜索中...";
            break;
        case MJRefreshStateNoMoreData:
            break;
        default:
            break;
    }
}

@end
